package com.sam.jvmgc;

/**
 * 相互引用垃圾回收！
 * @author Administrator
 *
 */
public class ReferenceCount {

	private Object instance;

	private static final int _1MB = 1024 * 1024;

	private byte[] bigSize = new byte[500 * _1MB];

	/**
	 * @param args
	 * @throws InterruptedException
	 */
	public static void main(String[] args) throws InterruptedException {

		ReferenceCount a = new ReferenceCount();

		ReferenceCount b = new ReferenceCount();

		a.instance = b;
		b.instance = a;
		System.gc();
		
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				
				while(true){
					
				}
				
			}
		}).start();

		 
	System.exit(0);
		
	}

	@Override
	protected void finalize() throws Throwable {
		// TODO Auto-generated method stub
		
		super.finalize();
		System.out.println( this.toString()+ ":被执行！");
	}

}
